<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        html,body{
            width:100%; height:100%;
        }
        body{
            overflow-x: hidden;
            background: transparent;
        }
        iframe{
            width:100%;
            height:100%;
            border:none;
        }
        #myframe{
            width: calc(100% - 15px);
        }
    </style>
</head>
<body>
<iframe id="myframe" src=""></iframe>
<a id="basePath" th:href="@{/}"></a>
<script src="../../../assert/js/jquery.js" th:src="@{/assert/js/jquery.js(v_=${@commonController.getSysConfigByPK('CACHE_CODE')})}"></script>
<script src="../../../assert/js/tagContab.js" th:src="@{/assert/js/tagContab.js}"></script>
<script type="text/javascript">
    $(".J_menuTab.active",window.parent.document).addClass("asdadasdada");
    var basePath = $("#basePath").attr("href");
    $.ajax({
        type: "get",
        url: basePath + "rest/tagManager/getTagAddress",
        data: {},
        success: function (data) {
            if (data.msg != "") {
                var myframe = document.getElementById('myframe');
                var dbasePath=basePath;
                myframe.setAttribute("src",data.msg+"/rest/page/tagDetail");
                window.addEventListener('message',function(e){
                    var username=sessionStorage.getItem("spanId");
                    var seatId=sessionStorage.getItem("seatId");
                    var proCode=sessionStorage.getItem("procode");
                    var areaId=sessionStorage.getItem("areaId");
                    if(e.data.msg==='loaded'){
                        //传入子页面信息
                        myframe.contentWindow.postMessage({data:{
                                username:username,
                                seatId:seatId,
                                proCode:proCode,
                                areaId:areaId,
                                dbasePath:dbasePath
                            }},e.data.url);
                    }
                    else if(e.data.msg==='close'){
                        var  dindex=parseInt($(".J_menuTab.active",window.parent.document).attr("data-index"));
                        var ctab=$(".J_menuTab[data-index='"+dindex+"']",window.parent.document);
                        var pactive=ctab.prev(".J_menuTab:last",window.parent.document);
                        pactive.addClass("active");
                        var did=ctab.prev().attr("data-id");
                        var dipnex=ctab.prev().attr("data-index");
                        $(".layui-nav-item .layui-this",window.parent.document).removeClass("layui-this");
                        $(".layui-nav-item  dd a[data-index='"+dipnex+"']",window.parent.document).parent("dd").addClass("layui-this");
                        $(".J_mainContent .J_iframe",window.parent.document).each(function () {
                            if ($(this).data("id") == did) {
                                $(this).show();
                                $(this).attr('src',did);
                            }
                        })
                        $(".layui-nav-item",window.parent.document).removeClass("layui-this");
                        $(".J_menuTab[data-index='"+dindex+"']",window.parent.document).remove();
                        $(".J_iframe[data-index='"+dindex+"']", window.parent.document).remove();

                    }
                });
            }
        }

    });
</script>

</body>
</html>